Skip to content

Update openai module compiler plugin to support generate API calls when the openai import is not present in the file#22

Merged
SasinduDilshara merged 5 commits intoballerina-platform:mainfrom
SasinduDilshara:fix-8126
Jul 27, 2025
Merged

Update openai module compiler plugin to support generate API calls when the openai import is not present in the file#22
SasinduDilshara merged 5 commits intoballerina-platform:mainfrom
SasinduDilshara:fix-8126

Conversation

@SasinduDilshara
Copy link
Contributor

Update ai module compiler plugin to support generate API calls when the ai import is not present in the file

Fixes: ballerina-platform/ballerina-library#8126

@codecov
Copy link

codecov bot commented Jul 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 35.74%. Comparing base (6c78945) to head (814f975).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #22   +/-   ##
=======================================
  Coverage   35.74%   35.74%           
=======================================
  Files           5        5           
  Lines         442      442           
  Branches      112      112           
=======================================
  Hits          158      158           
  Misses        284      284           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SasinduDilshara SasinduDilshara requested a review from Copilot July 27, 2025 06:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the AI module compiler plugin to support generating API calls even when the AI import is not present in the file being processed. The change addresses issue #8126 by modifying how the OpenAI model provider symbol is retrieved and referenced during code analysis.

Key changes:

  • Refactored symbol resolution to use the Types.getTypeByName() API instead of searching through visible symbols
  • Modified the analysis flow to pass the resolved OpenAI model provider symbol to document processing methods
  • Added test coverage for the scenario where AI imports are not present in the file

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
GenerateMethodModificationTask.java Updated symbol resolution logic to use Types.getTypeByName() and removed dependency on visible symbols
test_values.bal Added reviewRecord constant for test assertions
test-generate-method-usage-in-file-without-ai-import.bal New test file to verify functionality without AI imports
Dependencies.toml Updated dependency versions for ballerina/ai and ballerinax/ai.openai
CompilerPlugin.toml Updated compiler plugin JAR path to new version
Ballerina.toml Updated package version and native dependency path
Comments suppressed due to low confidence (1)

compiler-plugin/src/main/java/io/ballerina/lib/ai/openai/GenerateMethodModificationTask.java:142

  • [nitpick] The parameter name 'openAiModelProviderSymbol' in the method call is inconsistent with the variable name 'openAiModelProviderSymbol' declared at line 110. Consider using consistent naming throughout the method.
        analyzeGenerateMethod(semanticModel, modulePartNode, openAiModelProviderSymbol, this.analysisData);

@SasinduDilshara SasinduDilshara merged commit 50c1831 into ballerina-platform:main Jul 27, 2025
4 checks passed
@SasinduDilshara SasinduDilshara changed the title Update ai module compiler plugin to support generate API calls when the ai import is not present in the file Update openai module compiler plugin to support generate API calls when the openai import is not present in the file Jul 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON schema generation doesn't work for the generate method when there is no relevant import in that file

3 participants